home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / µSim 1.1 / source / Compares.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-27  |  1.0 KB  |  53 lines  |  [TEXT/CWIE]

  1. #include    "Compares.h"
  2.  
  3. #pragma fourbyteints on
  4. /* compareMnem: used to compare opcodes in the opcode table */
  5.  
  6. int compareMnem(const void *opc1, const void *opc2)
  7. {
  8. return(*(long *)opc1 - *(long *)opc2);
  9. }
  10.  
  11. /* cmpsymb: used to compare strings in the Symbol Table */
  12.  
  13. int cmpsymb(const void *opc1, const void *opc2)
  14. {
  15. return(RelString(**(StringHandle *)opc1, **(StringHandle *)opc2, true, true));
  16. }
  17.  
  18. int CompareFirstLast(const void *opc1, const void *opc2)
  19. {
  20. register unsigned short *tempP = (unsigned short *)opc2;
  21. unsigned short    d1, d2;
  22. int    d0;
  23.  
  24. d2 = *(short *)opc1;
  25. d0 = d2;
  26. d1 = *tempP++;
  27. if ((d0 -= d1) > 0) {
  28.     d0 = d2;
  29.     d1 = *tempP;
  30.     if ((d0 -= d1) <= 0)
  31.         d0 = 0;
  32.     }
  33.  
  34. return d0;
  35. }
  36.  
  37. /* compareOpc: compare function to search for the instruction
  38. currently executing */
  39.  
  40. int compareOpc(const void *opc1, const void *opc2)
  41. {
  42. register unsigned short *pntr;
  43. register unsigned short    a, b, c;
  44.  
  45. a = *(unsigned short *)opc1;
  46. pntr = (unsigned short *)opc2;
  47. b = *pntr++;
  48. c = *pntr;
  49. return ((c < a ? (int)1L : (int)0L) - (a < b ? (int)1L : (int)0L));
  50. }
  51. #pragma fourbyteints reset
  52.  
  53.